package com.work.service.impl;

import com.work.bean.Work;
import com.work.dao.DBDao;
import com.work.dao.impl.DBImpl;
import com.work.service.WorkService;
import com.work.utils.Constants;
import com.work.utils.SQLUtil;

import java.util.HashMap;
import java.util.List;

/**
 * Created by Administrator on 2017/10/7.
 */
public class WorkServiceImpl implements WorkService {

    private DBDao dao;

    public WorkServiceImpl() {

        dao = new DBImpl();
    }

    @Override
    public boolean insertWork(Work work) {

        return dao.insertAndDelAndUpdate(SQLUtil.insertWorkSql(work));
    }

    @Override
    public List<Work> findByTeacherId(int teacherId) {
        return dao.find(SQLUtil.findByTeacherIdSql(teacherId), Constants.WORK);
    }

    @Override
    public HashMap<Integer, List> pageByTeacherId(int countPage, int whichPage, int teacherId) {
        return dao.page(countPage, whichPage, SQLUtil.findByTeacherIdSql(teacherId), Constants.WORK);
    }

    @Override
    public boolean deleteById(String deleteId) {
        return dao.insertAndDelAndUpdate(SQLUtil.deleteByWorkId(deleteId));
    }

    @Override
    public boolean updateDistribute(int distribute,int workId) {
        return dao.insertAndDelAndUpdate(SQLUtil.updateDistribute(distribute,workId));
    }

    @Override
    public boolean updateFinishProcess(String process, int workID) {
        return dao.insertAndDelAndUpdate(SQLUtil.updateFinishProcess(process,workID));
    }

}
